
//Gets a 0-1 value from a value between 2 other values
function RangeScale(n,min,max,clamp)
    if(clamp==true) then return math.Clamp( (max-n)/(max-min) ,0,1) else return (max-n)/(max-min) end
end

//Concommand stuff to show/hide the money bar
moneyhud = 0
function ViewMoneyHud( ply, command, args)
	moneyhud = tonumber(args[1])
end
concommand.Add( "st_moneyhud", ViewMoneyHud ) 

//info regarding the repair huds
repairhud_info = {}

function STHud()

    //Repair Huds
    for n,hud in pairs(repairhud_info) do
        local shoulddraw = true
        ti,tf = math.modf(CurTime()*2)
        if(hud.val>0.33 or tf>0.5) then
            local min,max = 128,1024
            local scl = math.Clamp( (max-(LocalPlayer():GetShootPos()-hud.vec):Length())/(max-min) ,0.33,1)
            local pos = hud.vec:ToScreen()
            local x,y,w,h = pos.x-math.ceil(50*scl),pos.y-math.ceil(8*scl),math.ceil(100*scl),math.ceil(16*scl)
            draw.RoundedBoxEx( 2, x-2, y-2, w+4, h+4, Color( 0, 0, 0, 192 ) ,false,false,false,false)
            draw.RoundedBoxEx( 2, x, y, math.floor(w*hud.val), h, Color( 230, 32, 32, 192 ) ,false,false,false,false)
        end
    end
    table.Empty(repairhud_info)
    
    //Moneyhud
    if(moneyhud>0) then
        local money = LocalPlayer():GetNetworkedInt("st_money")
        local hold = LocalPlayer():GetNetworkedInt("st_moneyhold")
        draw.SimpleText( "Available: $"..money+hold.." / Spawned: $"..math.abs(hold), "Trebuchet24", ScrW()/2,ScrH()*0.96, Color(255,255,255,255),TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
    end
	
end
hook.Add("HUDPaint", "STHud", STHud)